Closed Bug 1240515 Opened 9 years ago Closed 9 years ago

[Static Analysis][ Incorrect deallocator used] In function nsNotifyAddrListener::OnNetlinkMessage from nsNotifyAddrListener_Linux.cpp

Categories

(Core :: Networking, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla46
Tracking Status
firefox46 --- fixed

People

(Reporter: andi, Assigned: andi)

References

(Blocks 1 open bug)

Details

(Keywords: coverity, Whiteboard: CID 1348503, CID 1348502)

Attachments

(1 file)

The Static Analysis tool Coverity added that these two smart pointers addr and localaddr are allocated using malloc, but the inside function of the smart pointers releases that memory through delete operator. The both variables instance nsAutoPtr<char>, having this the function that manages memory on deletion are: >> void >> assign(T* aNewPtr) >> { >> T* oldPtr = mRawPtr; >> >> if (aNewPtr && aNewPtr == oldPtr) { >> NS_RUNTIMEABORT("Logic flaw in the caller"); >> } >> >> mRawPtr = aNewPtr; >> delete oldPtr; >> } >> ~nsAutoPtr() >> { >> delete mRawPtr; >> } assign is called when we doing any assignment between nsAutoPtr<char> and nsAutoPtr<char> or char*. As i don't see where delete operator is overloaded to use our own allocator that would go through malloc i would convert the malloc function to new allocator.
Comment on attachment 8709039 [details] MozReview Request: Bug 1240515 - change allocator for addr and localaddr from malloc to new, since the smart pointer that is used uses delete operator. r=dragana https://reviewboard.mozilla.org/r/31237/#review27997
Attachment #8709039 - Flags: review?(dd.mozilla) → review+
Keywords: checkin-needed
this failed to apply: applying b4a96cbe991c patching file netwerk/system/linux/nsNotifyAddrListener_Linux.cpp Hunk #1 FAILED at 237 1 out of 1 hunks FAILED -- saving rejects to file netwerk/system/linux/nsNotifyAddrListener_Linux.cpp.rej patch failed to apply abort: fix up the merge and run hg transplant --continue
Flags: needinfo?(bogdan.postelnicu)
Keywords: checkin-needed
Comment on attachment 8709039 [details] MozReview Request: Bug 1240515 - change allocator for addr and localaddr from malloc to new, since the smart pointer that is used uses delete operator. r=dragana Review request updated; see interdiff: https://reviewboard.mozilla.org/r/31237/diff/1-2/
Attachment #8709039 - Attachment description: MozReview Request: Bug 1240515 - change allocator for addr and localaddr from malloc to new, since the smart pointer that is used uses delete operator. r?dragana → MozReview Request: Bug 1240515 - change allocator for addr and localaddr from malloc to new, since the smart pointer that is used uses delete operator. r=dragana
Flags: needinfo?(bogdan.postelnicu)
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla46
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: